home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume23 / zip / part04 < prev    next >
Encoding:
Text File  |  1991-10-20  |  54.0 KB  |  1,304 lines

  1. Newsgroups: comp.sources.misc
  2. From: kirsch@usasoc.soc.mil (David Kirschbaum)
  3. Subject:  v23i091:  zip - Portable zip v1.0, Part04/09
  4. Message-ID: <1991Oct21.042120.7985@sparky.imd.sterling.com>
  5. X-Md4-Signature: 112dd94095c7c795ea81a3ef538d0afb
  6. Date: Mon, 21 Oct 1991 04:21:20 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: kirsch@usasoc.soc.mil (David Kirschbaum)
  10. Posting-number: Volume 23, Issue 91
  11. Archive-name: zip/part04
  12. Environment: UNIX, Minix, MSDOS, OS/2, VMS
  13.  
  14. #! /bin/sh
  15. # into a shell via "sh file" or similar.  To overwrite existing files,
  16. # type "sh file -c".
  17. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  18. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  19. # Contents:  History makefile.pwc shrink.c zip.def
  20. # Wrapped by kent@sparky on Sun Oct 20 22:58:53 1991
  21. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  22. echo If this archive is complete, you will see the following message:
  23. echo '          "shar: End of archive 4 (of 9)."'
  24. if test -f 'History' -a "${1}" != "-c" ; then 
  25.   echo shar: Will not clobber existing file \"'History'\"
  26. else
  27.   echo shar: Extracting \"'History'\" \(36825 characters\)
  28.   sed "s/^X//" >'History' <<'END_OF_FILE'
  29. XNote, this history contains mail addresses and ftp locations that no longer
  30. Xexist, such as addresses at wsmr-simtel20 and directory names containing
  31. Xw8sdz, among others.  For problems, the correct email address is
  32. Xzip-bugs@cs.ucla.edu.
  33. X
  34. X------------------------ Nov  7  1990   version 0.0 ------------------------
  35. X------------------------ Nov  8  1990   version 0.1 ------------------------
  36. X------------------------ Nov 12  1990   version 0.2 ------------------------
  37. X------------------------ Nov 14  1990   version 0.3 ------------------------
  38. XThank you for your comments.  Here is Zip 0.3 with almost all of that fixed.
  39. XThe changes include:
  40. X
  41. X1. Put \n\ for newlines in long strings (everyone had this problem).
  42. X2. Wrote my own bsearch (called search---different args).
  43. X3. Wrote my own timelocal (called invlocal), used whether STDC or not.
  44. X   (Note to Greg: look at the code---I found a simple way to do it.)
  45. X4. -m now deletes empty directories also.
  46. X5. Changed crc.c to util.c and put search() in util.c.
  47. X6. Changed "void *" to "voidp *" and made voidp void for STDC, else char.
  48. X7. Removed -a option.
  49. X8. Some minor changes to zip.doc.
  50. X
  51. XI did not do anything about Cliff Manis's problem with DIR not being
  52. Xdefined.  DIR should have been defined in sys/dir.h.  If it wasn't, then
  53. Xthere's something wrong with dir.h, or it is missing, or the opendir, etc.
  54. Xfunctions are missing.  I don't really want to think about what to do for
  55. Xthe latter possibility.
  56. X
  57. XNUnzip 3.99 does not appear to be Unix-ready.  It fails for file names longer
  58. Xthan 12 characters (Segmentation fault), cannot find explicit names that
  59. Xdo not contain a dot, and does not notice the Unix identifier (which should
  60. Xswitch off name to lower-case mapping).
  61. X
  62. X------------------------ Nov 20  1990   version 0.4 ------------------------
  63. XYo Zippers,
  64. X
  65. XHere is a first attempt at a Zip intended to work on System V.  Try using
  66. X"make sysv" for such systems.  I also included replacements for memset()
  67. Xand memcmp() by Bill Davidsen and James Dugal for systems without those.
  68. XUse "make old" to include those routines.  Sun's use getdents() like Sys V,
  69. Xeven though it's BSD, so use "make sun".  For others, try just "make".
  70. X
  71. XWhen using "make" a second time with a different request, it's best to erase
  72. Xall the .o files to force recompiling everything.
  73. X
  74. XWhat follows are the changes I made and some things to try if you get it
  75. Xcompiled.  Have fun.
  76. X
  77. XMark
  78. X
  79. X
  80. XChanges from Zip 0.3 to Zip 0.4:
  81. X
  82. X1.  Changed third arg of search() to size_t to make lint happier.
  83. X2.  Replaced zip.doc with a man page, zip.1 (raw) and zip.man (formatted).
  84. X3.  rename() replaced with link() and unlink().
  85. X4.  Fixed vem in central header and added REVISION and REVDATE #define's
  86. X    to zip.h.  (Didn't read Phil's appnote.txt carefully enough there.)
  87. X5.  Removed prototypes except for development host (NeXT).  (They're only
  88. X    there for my benefit anyway---they should not affect the resulting
  89. X    code.  Consider them some meager documentation.)
  90. X6.  Changed rindex() to strrchr().
  91. X7.  Improved behavior on a write failure when -b is used.
  92. X8.  Added Bill Davidsen's and James Dugal's memset(), memcpy(), and
  93. X    memcmp() routines under the trusty ZMEM #define.
  94. X9.  Check that zip file is writeable before doing any real work.
  95. X10. Added #ifdef REGEX to use regcmp(), regex() instead of re_comp(),
  96. X    re_exec().  (We'll see if this works.)
  97. X11. Replaced opendir(), readdir(), closedir() with my own opend(), readd(),
  98. X    and closed() routines that use getdirentries() on BSD and getdents() on
  99. X    System V (I hope) and Sun's.  An #ifdef DIRENT selects getdents().
  100. X12. zip.h no longer #includes string.h, instead defining the string
  101. X    functions used explicitly.
  102. X
  103. X
  104. XIf you get Zip 0.4 to compile, here are some things to test:
  105. X
  106. X1.  Try zipping up some stuff, of course.  Use all the options that are
  107. X    implemented.  Especially try -rp and -rpm on a directory tree (use
  108. X    *test* files and directories, of course).
  109. X2.  Naturally check with unzip -t, but also check with "zip xxx" where
  110. X    xxx.zip is the zip file.  This should say "nothing to do", but if it
  111. X    says "error in zip file structure", there's a problem.
  112. X3.  After zipping, check that there are no $Z* files leftover.
  113. X4.  Try using -b, specifying a path on another device.  Check for $Z*'s.
  114. X5.  Try -d and a regular expression (like \*.o) on a zip file.
  115. X6.  And I'm interested in timing---try it on a 500K or so text file.
  116. X
  117. X------------------------ Nov 27  1990   version 0.5 ------------------------
  118. XHail fellow zippers,
  119. X
  120. XHere's Zip 0.5.  The biggie is it now includes implosion, courtesy of Rich
  121. XWales.  Even as we speak, he is working on new algorithms for implode that
  122. Xpromise to be significantly faster.  He might even get a paper out of it ...
  123. X
  124. XYou can use the -s option (shrink only) when testing to save a little time,
  125. Xbut also try it normally to test implosion (if you test with text files
  126. Xof reasonable length, implosion will be chosen for most of them).  Also, for
  127. Xspeed testing of implosion, use -i to not waste time trying to shrink.
  128. X
  129. XIncluding implosion about doubles the size of zipnn.tar.Z, so I would like
  130. Xsome input on distributing subsequent versions.  Would y'all like to keep
  131. Xon getting the uuencoded version via mail, or would you prefer a notice
  132. Xabout availability via anonymous ftp on simtel20.army.mil in <w8sdz.zip>?
  133. X(I have been sending the previous versions to Keith to put there, and will
  134. Xcontinue to do so.  I do not know what the lag time is for him to move it
  135. Xthere.)
  136. X
  137. XThe other important change is that this is another attempt at getting the
  138. Xdirectory access routines working on all systems.  Read the installation
  139. Xpart of the manual page (zip.man).  And if you feel like, read the whole
  140. Xthing.  I'm also taking suggestions for and bugs in the documentation.
  141. X
  142. XThe differences from Zip 0.4 include:
  143. X
  144. X1. Changed all occurences of "size_t" to "extent" and typedef'ed extent
  145. X   to size_t (after an #include <stddef.h>) for ANSI C, or unsigned int
  146. X   otherwise.  If anyone finds that they have a non ANSI C, that size_t
  147. X   is defined, and that it is not the size of the compiler's int, then
  148. X   please let me know.
  149. X2. Changed help() to put the help text in a static array of strings and
  150. X   then printf() for each line.  Some compilers barfed on the long
  151. X   string.  Suggested by davidsen@crdos1.crd.ge.com.
  152. X3. Added Rich Wales' implode routines, made their inclusion the default
  153. X   (changed #ifdef IMPLODE to #ifndef NOIMPLODE).
  154. X4. Put "extern int errno;" in unixfile.c (redundant extern's should be ok).
  155. X5. Minor changes to the man page (zip.1 and zip.man).
  156. X6. Added warnings for names given on the command line that are not matched.
  157. X   Lack pointed out by grimesg@sj.ATE.SLB.COM (George).
  158. X7. Changed back to opendir(), etc. on BSD systems.
  159. X8. Added NDIR #define for HPUX to #include <ndir.h> instead of <sys/dir.h>.
  160. X9. Redid Makefile, adding next (use shared library), sysvpw (System V's
  161. X   that require linking the libPW library for regex routines), and hpux
  162. X   (see #8 above).
  163. X
  164. XAs usual, report problems to info-zip@wsmr-simtel20.army.mil.  If you wish,
  165. Xyou can, in addition, send the same report to me (madler@piglet.caltech.edu)
  166. Xor Rich (wales@cs.ucla.edu) if the problem is with implosion (i* files) for
  167. Xquicker reponse.
  168. X
  169. Xyour humble servant,
  170. XMark Adler
  171. X------------------------ Dec  7  1990   version 0.6 ------------------------
  172. XGreetings and Felicitations Honorable Zip Compatriots,
  173. X
  174. XI have uploaded Zip 0.6, which incorporates most of your helpful comments,
  175. Xto Simtel20.Army.Mil, and it should evenually end up in <W8SDZ.ZIP> as
  176. XZIP06.TAR-Z.  The most significant change is the addition of encryption
  177. Xboth as the -e option in Zip, and a new program, ZipCloak, that encrypts
  178. Xand decrypts zip entries.  This surely adds some new portability problems,
  179. Xdue to the getp() routine which reads a password from the terminal with no
  180. Xechoing.  We'll see how well this flies ...
  181. X
  182. XIf someone wants to PKZIP up the tar.Z file, please do so.  I didn't zip
  183. Xit up myself because a) I'm lazy, and b) PKZIP can compress it better
  184. Xanyhow, and I don't have a PC.
  185. X
  186. XAlso, there is an EXPORT symbol used to remove encryption, so I can make
  187. Xan export version that does not have -e or ZipCloak.  This version will
  188. Xsimply be missing a few source files and have a different Makefile.
  189. X
  190. XI also added a few systems to the Makefile, and made some other changes to
  191. Xit based on all your detailed comments.  If it still works after all that,
  192. XI'll be amazed.
  193. X
  194. XThose and other changes from 0.5 to 0.6 are detailed at the end of this note.
  195. X
  196. XI have not addressed the portability problem with the implode routines,
  197. Xsince that is Rich's domain.  I have no idea what is causing it.  (For those
  198. Xwho don't know, one system produced remarkable 90% compression rates with
  199. Ximplode, but alas, it is a bug.)
  200. X
  201. XOne fellow complained that zipping up the README file results in a zip file
  202. Xthat is larger than the original, even though Zip claims it compressed it.
  203. XWell, it did compress it, but the ZIP file format has an overhead of
  204. X76+2*N bytes per file+22 bytes, where N is the length of the file name.
  205. XAnd that's without comments or "extra" information.  So, a zip file with a
  206. Xsingle file whose name has six characters has an overhead of 110 bytes.
  207. XREADME gets shrunk by 16% from 274 bytes to 230 bytes, resulting in a total
  208. Xzip file size of 340 bytes---larger than the original file (274 bytes).
  209. XThe moral is don't expect zip to compress a single small file.  The other
  210. Xmoral is use unzip -v to see the compression.
  211. X
  212. XSomeone else asked about multi-disk zip files.  I'm not sure I believe in
  213. Xthose, since PKZIP and PKUNZIP do not appear to suppport them (though it is
  214. Xpart of the ZIP file definition in APPNOTE.TXT).  What I was planning on
  215. Xdoing for that case was to write a ZipSplit program that would take a large
  216. Xzip file and try to optimally split it into the fewest number of zip files
  217. Xthat are all less than the specified size.  Each would be a complete, stand
  218. Xalone zip file---not part of a single, multi-disk zip file.  There would
  219. Xalso be a ZipMerge program.
  220. X
  221. XThis is the version of Zip that will live in infamy (note the revision date).
  222. XOf course, some current Presidents of the United States think that should be
  223. XSeptember 7th, but I won't name any names.
  224. X
  225. XI am going on vacation for about two weeks, so I expect to find many new
  226. Xproblems reported upon my return.
  227. X
  228. XAnd lastly, for my Holiday Greetings: Party On Dudes.
  229. X
  230. XMark Adler
  231. Xmadler@piglet.caltech.edu
  232. X
  233. X
  234. XHere are the changes from Zip 0.5 to Zip 0.6:
  235. X
  236. X1.  Minor documentation changes (zip.1 and zip.man).
  237. X2.  Fixed an embarrasing lack of recursion in opend/readd/closed functions
  238. X    that only existed in 0.5.
  239. X3.  Moved $(LDFLAGS) to end of the linking command line in Makefile.
  240. X4.  Added make dnix for DNIX 5.2, 5.3 not using optimization (no -O).
  241. X5.  Wrote ZipCloak for encryption and decryption.
  242. X6.  Rich changed the output routines of implode to use zfwrite and zputc to
  243. X    provide hooks for encryption (defined in crypt.h).  Also removed
  244. X    function prototypes unless PROTO defined.
  245. X7.  Added encryption (-e) to Zip.
  246. X8.  Added make pyramid (use rindex() instead of strrchr()).
  247. X9.  Changed make to $(MAKE) and cc to $(CC) in Makefile.
  248. X10. Took out strip in Makefile.
  249. X11. Changed year from 1991 to 1990.  (How'd *that* get in there?  Of course,
  250. X    it's not as bad as when I wrote a check the other day and dated it 1977.
  251. X    I think my brain cell isn't working as well as it used to.)
  252. X12. Added make cray (use scc instead of cc).
  253. X13. Added make amdahl (use system() instead of rmdir()).
  254. X14. Added entry of one-line comments for added files (-c).
  255. X15. Put comment delimiters around name following #endif's in Rich's code.
  256. X
  257. X------------------------ Feb 13  1991   version 0.7 ------------------------
  258. XFellow stuck zippers,
  259. X
  260. XWell folks, it's been a while since 0.6. so there have been a lot of
  261. Xchanges on the way to 0.7.  The exhaustive listing is below, but here are
  262. Xsome highlights ...
  263. X
  264. XImplode now (appears) to be PKUNZIP compatible.  There were many odd
  265. Xlittle requirements implosed by the coding of PKUNZIP that were obtained
  266. Xfrom Phil Katz and associates.  Now that Rich has that working, he will
  267. Xlikely be working on much faster string matching routines to speed up
  268. Ximplode.
  269. X
  270. XUser interrupts (control-C or kill) are now caught and the temporary files
  271. Xare deleted, making for a clean getaway.
  272. X
  273. XSelf-extracting zip files for MSDOS can now be processed, with the
  274. Xextensions zip, ZIP, exe, or EXE.  This allows you to make self-extracting
  275. Xzip files for MSDOS by taking an existing one (like PKZ110.EXE) and
  276. Xdeleting all the entries to get a prototype self-extracting zip file that
  277. Xcan be copied and added to.  Of course, you should only do this if you are
  278. Xa registered user of PKZIP.  Note that if the file does not end in .zip,
  279. Xyou have to give the full name.
  280. X
  281. XI have relaxed some of the restrictions on zip files to allow processing
  282. Xones with "authenticity verification" (applied by the PUTAV program that
  283. Xcomes with PKZIP).  Of course, the authenticity no longer checks out if
  284. Xyou muck with the file, but at least you can muck with it now.
  285. X
  286. XThe Makefile has been considerably simplified, thanks to suggestions from
  287. XJean-Loup Gailly.  Also, I wrote my own sh expression matcher, eliminating
  288. Xthe regular expression hassles, and the REGEX symbol and -lPW options in
  289. Xthe Makefile.
  290. X
  291. XMany, many cosmetic changes, the most dangerous of which was turning on
  292. Xprototypes again in the hopes we can get them to work.  If they cause you
  293. Xproblems, record the problems (for me), and then add a -DNOPROTO to the
  294. Xappropriate line in the Makefile and try again.
  295. X
  296. XThis version now compiles under Microsoft C 5.1 and Turbo C++ 1.0, with
  297. Xmuch thanks to Jean-Loup Gailly.  I say "compiles" and not "works" because
  298. XI have not thoroughly tested it.  It does work, but there may be errors in
  299. Xthe port as well as errors in the design.  By the latter I mean that there
  300. Xmay be some disagreement over what you expect it to do and what it does,
  301. Xespecially with regards to upper and lower case names and wildcard
  302. Xpatterns.  Also, the implode routines do not yet work under MSDOS, so the
  303. Xcompilations are done using NOIMPLODE.  There are two dumb batch files to
  304. Xdo the compile: doturboc.bat and domsc.bat.  If someone would like to
  305. Xwrite make files for the make utilities that come with those languages,
  306. Xplease be my guest.  I'm just too lazy.  However, I would probably resist
  307. Xincluding make files that require a make utility that does not come with
  308. Xthose languages, be it commercial, shareware, or free.
  309. X
  310. XThere are two new programs: ZipSplit and Ship.  ZipSplit tries to split a
  311. Xbig zip file into the smallest number of zip files less than a specified
  312. Xsize.  This is to aid in using zip to backup to floppies.  It has the
  313. Xlimitation that it cannot break up an entry in a zip file, since it makes
  314. Xcomplete, standalone zip files.  This means if any entry is larger than
  315. Xthe specified size (plus some overhead), zipsplit will give up and not do
  316. Xthe split.  It does *not* implement the multi-disk zip file format implied
  317. Xin APPNOTE.TXT.  ZipSplit will optionally write an index file and deduct
  318. Xthe size of that file from the first zip file so both will fit on the
  319. Xfirst disk.
  320. X
  321. XShip is a fixed-up version of a program I have been using myself for some
  322. Xtime in place of uuencode/uudecode.  It's purpose is to facilitate sending
  323. Xzip files through the mail.  It uses a more efficient coding scheme than
  324. Xuuencode (four bytes per five characters instead of three bytes per four
  325. Xcharacters) and includes a crc at the end of each file to check the
  326. Xveracity what was received.  It can split its output to a specified size
  327. Xand recombine it automatically at the other end, verifying the sequence.
  328. XIt can also mail the parts to a specified address, with subject lines
  329. Xidentifying the parts, instead of making a bunch of files that you're just
  330. Xgoing to mail and delete anyway.  Example:
  331. X
  332. X     % ship -500 -m saddam@pickle.iq README zip07.zip
  333. X     README shipped
  334. X     zip07.zip shipped
  335. X     files part0001..part0004 mailed
  336. X
  337. Xwill mail README and zip07.zip together in four chunks of 500 or fewer
  338. Xlines each.  At the other end, Saddam can save the parts into the files
  339. Xnamed in the subject lines (part0001..part0004), and then do:
  340. X
  341. X     % ship -u part*
  342. X     README received
  343. X     zip07.zip received
  344. X
  345. XFor now, zip.1 (and zip.doc) are incomplete as far as MSDOS goes.  I'll
  346. Xput off doing that until the MSDOS version has stabilized.  Likewise, I
  347. Xhave put off writing zipcloak.1, zipsplit.1, and ship.1 for the same
  348. Xreason.
  349. X
  350. XThere are, of course, all the little changes that fix bugs (what are
  351. Xthose?), make the Makefile work on more systems, documentation, and,
  352. Xfor the alert reader, an undocumented option ...
  353. X
  354. XAs usual, send reports to info-zip@wsmr-simtel20.army.mil, so everyone
  355. Xcan get a chuckle out of whatever new bugs I've introduced.
  356. X
  357. XMark Adler
  358. Xmadler@pooh.caltech.edu
  359. X
  360. X
  361. XChanges from release 0.6 to release 0.7:
  362. X
  363. X1.  Changed Makefile to use mv instead of -o on compiles.
  364. X2.  Added MAKE = make to Makefile.
  365. X3.  Catch user interrupt or termination and delete temporary files.
  366. X4.  Allow general purpose flags in local and central headers to differ in
  367. X    the "reserved" bits.  Keep both for copying zip entries verbatim.
  368. X5.  Removed prototype for closedir--return value not used and inconsistent
  369. X    across systems.
  370. X6.  Wrote ZipSplit to break a large zip file into the smallest number of
  371. X    zip files less than a specified size.  Run zipsplit with no arguments
  372. X    to see the command help.
  373. X7.  Put error messages in globals.c to be common across zip, zipcloak, and
  374. X    zipsplit.  Use #define's in zip.h for error numbers.
  375. X8.  Changed getp() to open a new file for the terminal device, and added
  376. X    the echon() function to turn echoing back on when interrupted at
  377. X    password prompt.
  378. X9.  Added warn()'s to distinguish various zip file structure errors.
  379. X10. Allow "extra" fields in local and central headers to differ.
  380. X11. Fixed percent compression calculation to work for very large files.
  381. X12. Included the program (makecrc.c) that generates the CRC table.
  382. X    makecrc.c is not compiled or run by the Makefile, but is present for
  383. X    completeness.
  384. X13. Added an undocumented (except for here) option, -v, to zip that checks
  385. X    for "oddities" in the zip file structure and points them out if found
  386. X    (but continues processing).
  387. X14. Put prototypes in crypt.h inside #ifdef NeXT to avoid redefinition
  388. X    problems with other compilers.
  389. X15. Added "make zilog" for Zilog S8000 running Zeus 3.21.
  390. X16. Minor changes to the manual page (zip.1 and zip.doc).
  391. X17. Fixed bug in replace() (manifested by -b option).
  392. X18. readzipfile() now also checks the central directory start and size in
  393. X    the end of central directory header.
  394. X19. Allow modification of self-extracting zip files (exe instead of zip).
  395. X20. Allow .ZIP as valid suffix as well as .zip (also .EXE and .exe).
  396. X21. Cleaned up malloc usage, free'd everything malloc'ed.
  397. X22. fclose'd all fopen'ed files explicitly.
  398. X23. Corrected assignment of one ftell() result from an int to a long.
  399. X24. Considerably simplified Makefile, based on Jean-Loup Gailly's
  400. X    suggestions.
  401. X25. Renamed unixfile.c to fileio.c in anticipation of non-unix support.
  402. X26. Removed const's (pesky little buggers caused too many problems).
  403. X27. Wrote my own shell expression compare routine, took REGEX and -lPW's
  404. X    out of Makefile, which removed the sysvpw make option.
  405. X28. Added tempname() prototype to crypt.h for the implode routines to use.
  406. X29. Trying string.h for prototypes of string functions if __STDC__
  407. X    defined, which is what unzip.h does.
  408. X30. Turned prototypes on if __STDC__ defined (we'll try this one more
  409. X    time).  They can be turned off using NOPROTO.
  410. X31. Improved source documentation.
  411. X32. Changed prototype of open in fileio.c to OF((char *, int, ...)).
  412. X33. Removed "local" from prototypes of main() (after all, it's *not*
  413. X    local).
  414. X34. Wrote Ship program to supplant uuencode--slightly more efficient, has
  415. X    error checking, file splitting, automatic mailing, other features.
  416. X    Ship currently uses the command:
  417. X        /usr/ucb/mail -s subject < tempfile
  418. X    to send mail.  Please let me know what works for your system.  Note
  419. X    that I want to be able to specify a subject line.
  420. X35. Ported to MSDOS Microsoft C 5.1, based on Jean-Loup Gailly's work.
  421. X36. Fixed add/update bug when -p not used.
  422. X37. Handle lower case conversion and devices (e.g. C:) for MSDOS.
  423. X38. Indented the #ifdef/#ifndef constructs that do not contain function
  424. X    definitions, to improve the readability somewhat.
  425. X39. Cleaned up error handling.  Now use perror() for i/o errors.  Put the
  426. X    errors and messages in ziperr.h.
  427. X40. Ported to MSDOS Turbo C++ 1.0.
  428. X41. Implemented wild card expansion on the command line for MSDOS and
  429. X    handle MSDOS matching (*.* == all, not *).
  430. X42. Changed version required to unzip to 11 (1.10) since the implode
  431. X    routines can procude an overlapping match one away from the end of the
  432. X    window (PKUNZIP 1.00 requires two away from the end).
  433. X43. Changed old next make option to next10 (for version 1.0) and added a
  434. X    new next make option for 2.0 (just called next) that uses the -object
  435. X    linking option for smaller executables.
  436. X44. Added -z option to take a multi-line zip file comment from stdin.
  437. X45. Changed temporary names from $ZXXXXXX to _ZXXXXXX, where XXXXXX is
  438. X    filled in by mktemp().  This avoids problems with "rm $Z*" in sh.
  439. X46. Got new implode routines from Rich that are (hopefully) PKUNZIP
  440. X    compatible.
  441. X47. When -b is not specified, put the temporary files in the same
  442. X    directory (i.e. the same device) that the zip file is (or will be) in.
  443. X48. Added doturboc.bat and domsc.bat files to compile for Turbo C++ 1.0
  444. X    and Microsoft C 5.1.  I am interested in successes and failures with
  445. X    other versions of those compilers.  In this version, the implode
  446. X    routines do not work under MSDOS.
  447. X------------------------ May  6  1991   version 0.8 ------------------------
  448. XBuenos Dias Amigos,
  449. X
  450. XHeer ees dee Cinco de Mayo reeleese of seep, aka Zip 0.8.  The changes
  451. Xfrom 0.7 are in the (long) list below, but here are some highlights:
  452. Xfaster implode, faster shrink, first attempt at a VMS version (thanks
  453. Xto Cave Newt), and a new program, ZipNote, to aid in editing zip file
  454. Xcomments.  To compile under VMS, do an "@makevms.com".  To compile using
  455. XMircosoft C do a "make makefile.msc".  To compile using Borland (Turbo)
  456. XC, do a "make -fmakefile.bor".  Please try to break any or all of these
  457. Xprograms in every conceivable way--we're getting close a public release.
  458. XThank yew fer your support.
  459. X
  460. XMark Adler
  461. Xmadler@pooh.caltech.edu
  462. X
  463. XChanges from 0.7 to 0.8:
  464. X
  465. X1.  Added the -n option to prevent compressing already compressed files.
  466. X    Documented -n in zip.1.
  467. X2.  Check the length of the compressed data in zipup() in case implode or
  468. X    shrink has a bug.
  469. X3.  Fixed -v option to not complain about needing PKUNZIP 1.1.
  470. X4.  Added report of store/shrink/implode sizes when -v (verbose) used.
  471. X5.  Put in Rich's patch to fix 100% implosion bug.
  472. X6.  Fixed -i bug.
  473. X7.  Made changes to im_ctree.c and implode.c to (hopefully) make it work
  474. X    under MSDOS.  (Jean-Loup said declare topmaxvals and botmaxvals as
  475. X    U_INT in im_ctree.c, and use MSDOS, not __MSDOS__ in implode.c.)
  476. X8   Added implode routine compilation to domsc.bat and doturboc.bat.
  477. X9.  Replaced FILENAME_MAX with FNMAX, which is now always 1024.  (It seems
  478. X    FILENAME_MAX is incorrectly set to 14 on some System V Unixii.)
  479. X10. Changed BEST to -1 so it is different from STORE (=0).  Redid some of
  480. X    the method logic in zipup().
  481. X11. Changed wb+ to w+b in implode.c.
  482. X12. Removed "nothing to do" error for -u and -f.
  483. X13. Zip source distributions will now have tabs removed, except for
  484. X    Makefile and Makefile.exp (no feelthy tabs rule).
  485. X14. Changed zip error on open failure to a warning.  This accounts for
  486. X    files that do not have read permission or are locked, and files
  487. X    deleted during the zip.  For entries being updated, the old entry is
  488. X    copied over instead.  This change had the side effect of removing the
  489. X    zipskip() routine.
  490. X15. Removed OBJC dependencies in Makefile.exp (didn't belong).
  491. X16. Removed strip from Makefile, instead using the -s link option.
  492. X17. Fixed -um and -fm to delete files whose entry's times were checked in
  493. X    the archive.
  494. X18. Put portability stuff common to zip.h and crypt.h into tailor.h.
  495. X19. Added mark tracing to -v (for debugging).
  496. X20. Changed name and zname logic--an external name is always converted
  497. X    into an internal zname, and vice-versa.  zname is now always
  498. X    malloc'ed.
  499. X21. Fixed -z to use CRLF between lines (for PKZIP) and have no newline
  500. X    after the last (or only) line.
  501. X22. Added clean to Makefile (deletes *.o, zip, zipcloak, zipsplit, ship).
  502. X23. Replaced LDFLAGS with LFLAGS1 and LFLAGS2 in Makefile (splits link
  503. X    options before and after object files as in unzip).
  504. X24. Added scodos to Makefile (from Bill Davidsen).
  505. X25. Included stdio.h in tailor.h--removed stdio.h from zip.h and
  506. X    implode.h.
  507. X26. Do not include stddef.h if M_XENIX defined.
  508. X27. Cast the arguments of all free() calls to (voidp *).
  509. X28. Added casts to char * for memset() and qsort() args in zipsplit.c.
  510. X29. Changed implode.h to define malloc and str* properly.
  511. X30. Fixed invlocal() to handle integer overflow correctly, as well as
  512. X    reliably across compilers.
  513. X31. Got new implode.h from Rich with fix #29 above.  Removed stdio.h
  514. X    include.
  515. X32. Commented out the abort() calls in im_ctree.c.
  516. X33. -ee requests a verification of the encryption password.
  517. X34. malloc and free tempath.
  518. X35. Documented -, SCO, and scodos in zip.1, and - in help().
  519. X36. Added revision.h for Zip revision number and date.
  520. X37. -u and -f with no arguments now (both) freshen the entire archive.
  521. X38. Use /Oait instead of /Ox for MSC to avoid loop optimization (buggy on
  522. X    5.1, and sometimes even crashes compiler!).
  523. X39. Added ! (reverse) range matching to shmatch(), and early abort on '*'
  524. X    failures (speeds up pathological patterns).  Cleaned up '\' (escape)
  525. X    handling.
  526. X40. Changed '!' in ship to '{' (some EBCDIC translations do not include
  527. X    !).  However, unship (ship -u) still understands '!'.  Also added the
  528. X    -v option of ship to print out the version and revision date.  Also
  529. X    now refuse to overwrite an existing file when unshipping (ship -u),
  530. X    but there is a -o option to overwrite anyway.
  531. X41. Added a "fast" mode to ship using hard-arithmetic coding that is
  532. X    nearly as efficient as base 85 coding, but much faster on 16-bit
  533. X    machines (base 85 coding uses 32 bit multiplication and division).
  534. X42. Put tailor.h back in ship.c, so that ship.c can stand on its own.
  535. X43. Made -p the default, and added a new option, -j to do the opposite
  536. X    (junk directory names).  -p is still there but does nothing, so as to
  537. X    avoid annoying PKZIP users.  Changed documentation and help()
  538. X    accordingly.
  539. X44. If -j is used, and two files are to be added with the same name, then
  540. X    zip exits with an error.
  541. X45. Wrote ZipNote for editing zipfile comments.  Just do zipnote for
  542. X    usage.
  543. X46. Replaced Rich's im_lmat.c with a new one from Jean-Loup.  Improves the
  544. X    speed of implode by a factor of two, and even more for very large
  545. X    files.
  546. X47. Reduced the execution time of shrink by 33% simply by moving the code
  547. X    around (eliminated some unnecessary calls, moved some tests).
  548. X    Shrink's execution time is now about 50% more than compress (it used
  549. X    to take over twice as long).  Hash tables for shrink are still
  550. X    intended for a future release.
  551. X48. VMS mods from Greg: replace() unlinks only after copy, changed
  552. X    delete() to destroy(), added code for deletedir(), use creation time
  553. X    instead of modification time, warn if stamp() attempted, changed
  554. X    includes, make link rename and unlink delete, added findfirst,
  555. X    findnext stuff, added wild() for VMS, modified newname(), procname().
  556. X49. Implemented internal<-->external name conversions for MSDOS and VMS.
  557. X50. For VMS matching, changed ? to %, removed bracketed ranges.
  558. X51. Added makevms.com, stolen from Unzip (vms_make.com).
  559. X52. Implemented -k (force the zip file to look like it was made by PKZIP).
  560. X53. Removed implode for VMS (it crashes--haven't tracked down where).
  561. X54. Got Jean-Loup's makefile.dos working for MSC 5.1 (makefile.msc) and
  562. X    Turbo C++ 1.0 (makefile.bor).
  563. X------------------------ Jul 11  1991   version 0.9 ------------------------
  564. XHey gang,
  565. X
  566. XHere is our very-nearly-ready-to-release version of Zip.  There will be no
  567. Xfeatures added or changed from 0.9 to 1.0--only bugs fixed.  I hope that
  568. Xwe can get 1.0 out pretty quickly then.  This is really your last chance to
  569. Xfind bugs before it goes out, so please, please test all the programs as
  570. Xmuch as you can.  Try all the features, if possible, and perhaps try to
  571. Xthink of ways to break the programs.  Also, and this is very important, read
  572. Xthe documentation in zip.doc and "debug" that too.  I already know that it
  573. Xis not complete in 0.9, but please send any comments about errors, omissions,
  574. Xformat, or whatever to Info-ZIP, even if they seem obvious.
  575. X
  576. XThe highlights of the changes from 0.8 to 0.9 are: faster, slicker implode;
  577. Xoperation in small model on MSDOS for speed; a new temporary file interface
  578. Xfor faster operation on small files; some shrink improvements; and some new
  579. Xoptions (-y, -g, -q).  Also, ship has been enhanced in several ways, not the
  580. Xleast of which is a help option (-h).
  581. X
  582. XHave fun.
  583. X
  584. XMark Adler
  585. Xmadler@tybalt.caltech.edu
  586. X
  587. X
  588. XChanges from 0.8 to 0.9:
  589. X
  590. X1.  Removed the "not implemented yet" note in help() for -k (it *is*
  591. X    implemented now).  Removed from bug list in zip.1 too.
  592. X2.  Fixed Turbo C implode bug.
  593. X3.  Added /link /e in makefile.msc for ship.c.
  594. X4.  Made handler() in zipnote.c the same as handler() in zipsplit.c.
  595. X5.  Added -y option in Unix to store symbolic links as such.  (We need
  596. X    Unzip to be aware of symbolic links and use symlink() to recreate them.)
  597. X6.  Ignore control characters in unship input.
  598. X7.  Use prototypes and ANSI libraries if MSDOS.  (Used to check for Turbo C,
  599. X    but Microsoft C 6.0 also does not define __STDC__ unless strict ANSI
  600. X    is requested.)
  601. X8.  Added mod to ct_fsort() from Rich that should remove any qsort()
  602. X    dependencies in implode output.
  603. X9.  Removed some 32/16-bit prejudices in util.c and crypt.c that affect
  604. X    64-bit integer (short, int, and long) machines (Cray).
  605. X10. Added System V MAILX option to ship.c to use the mailx command.  This
  606. X    is automatically activated by DIRENT if ship is compiled by the zip
  607. X    makefile.
  608. X11. Added patches from Greg Roelofs for echo control on Cray and Amdahl.
  609. X    The patch uses termio.h and ioctl(), and is assumed for all System V,
  610. X    not just those (we'll see how this flies).
  611. X12. Changed -Ox to -Oacegit -FPi87 in makefile.msc.  Added /nologo to link.
  612. X13. Applied J-L's 082 mods (Sinatra style): select 4K window for < 5.5K,
  613. X    8K window for >= 5.5K files (just like PK does); various im_ctree.c
  614. X    mods verbatim (except for the treename warning, which I did differently);
  615. X    various im_lmat.c mods verbatim (except macros are done the ugly portable
  616. X    way); farmalloc'ed in shrink.c; changed makefile.msc and makefile.bor to
  617. X    use small model; added J-L to zip.1 acknowledgements (oops).
  618. X14. Moved struct zlist's and struct flist's to far storage (needed by above
  619. X    mods).  Unfortunately, I can't move the names and other things pointed to
  620. X    by those structures into the far space, since they are arguments to
  621. X    library functions like strcmp() and fwrite().
  622. X15. Changed zipup() to both shrink and implode only on files smaller than
  623. X    BSZ.  Also in that case, free up shrink data structures before allocating
  624. X    the implode data structures.  Changed from fopen() to open() except for
  625. X    VMS.
  626. X16. Fixed bug in dosmatch() to free malloc'ed space.
  627. X17. MINIX mods (do not need minix make option): call tempname() with a unique
  628. X    character (MINIX mktemp() flawed); defined S_IWRITE as S_IWUSR if S_IWUSR
  629. X    defined; removed explicit signal dereference.
  630. X18. Fixed bug in unship when used as a filter with no args.
  631. X19. Changed getnam() to not use static storage.
  632. X20. Copy permissions from old to new zip file (zip, zipcloak, zipnote).
  633. X21. Added patches for AT&T 3B1, added 3b1 target to makefile, added to zip.1.
  634. X22. Made FNMAX 256 for MSDOS (is 1024 otherwise).
  635. X23. Used the "pyr" predefined symbol for Pyramid systems in tailor.h.
  636. X24. Added Greg's VMS mods to ship.c.  Added help to ship.c (-h or -?).
  637. X    Changed meaning of -nnn arg from lines to K.
  638. X25. Moved ZMEM routines to fileio.c to properly include them in zipnote and
  639. X    zipsplit.
  640. X26. Added -s option to ship to specify a subject line prefix.
  641. X27. Fixed -z in zip to not trash leading blank lines in the comment.
  642. X28. Made ship recognize "unship" in argv[0] a little more flexibly.
  643. X29. Made sure temporary zip files are closed before being deleted by an
  644. X    error or interrupt.
  645. X30. Added a new temporary file interface and new source files tempf.c and
  646. X    tempf.h.  This avoids making temporary files for small (<16k) output.
  647. X    Both shrink and implode use this.
  648. X31. Added OS/2 patches, files.  However, left zip case-sensitive for OS/2
  649. X    names, as in Unix.
  650. X32. Removed amdahl target in makefile, using UTS symbol instead.
  651. X33. Changed -y to depend on definition of S_IFLNK.
  652. X34. Avoid leading periods on lines in ship output by inserting a space.
  653. X35. Ship is now extensible: added a warning for "unsupported keyword".
  654. X    Such keywords can appear before the "ship" line, for example.
  655. X36. Added -g option to allow "growing" the zip file.  If just adding new
  656. X    entries to a zip file, -g will write over the old zip file without
  657. X    creating a temporary.  The danger is that if there is an error, the
  658. X    old zip file will be lost.  If not just adding, then -g is ignored.
  659. X37. Added aux (A/UX) target to makefile.
  660. X38. In shrink.c, removed unnecessary FreeList and ClearList arrays, and
  661. X    the recursive Prune() routine.  This also resulted in a speedup in
  662. X    shrink of about 15%.  It is now only about 30% slower than Unix compress.
  663. X39. Added -q option for quiet operation.
  664. X------------------------ Sep 21  1991   version 1.0 ------------------------
  665. XHello world!
  666. X
  667. XThis is the first public release version of Zip and its cohort utilities.
  668. XWe hope you enjoy using it much much more than we enjoyed writing it and
  669. Xtrying to get it to work on every fritzing raffing bliffing nobbin Unix
  670. Xsystem in the galaxy.
  671. X
  672. XPlease feel free to send any problems, complaints, suggestions, kudos,
  673. Xridicule, or whatever to zip-bugs@cs.ucla.edu.  If there were a way to
  674. Xsend cookies over the net, we'd accept those too.
  675. X
  676. XThank yew fer yur support.
  677. X
  678. XMark Adler
  679. Xmadler@tybalt.caltech.edu
  680. X
  681. X
  682. XChanges from 0.9 to 1.0:
  683. X
  684. X1.  Removed some pesky carriage returns masquerading as spaces in fileio.c
  685. X    and zipup.c.
  686. X2.  Removed #include memory.h in tempf.c (string.h good enough).
  687. X3.  Compile ship in doturboc.bat.
  688. X4.  Miscellaneous zip.1 (zip.doc) changes.
  689. X5.  Fixed mistake in stamp() in fileio.c (didn't double seconds).
  690. X6.  Applied Jean-Loup's mods for Cray's (do not assume 16-bit shorts).
  691. X7.  Removed pyramid make option, since #ifdef pyr seems to work.
  692. X8.  Added some casts to tempf.c to clean up some warnings.
  693. X9.  Added comment to makefile.exp saying what it is.
  694. X10. Removed length checks in zipup.c to fix problem with using Vax variable
  695. X    record length formats.
  696. X11. Fixed VMS replace-across-devices problem.
  697. X12. Changed order of include's in implode.h to make tailor.h show up first.
  698. X13. Added Convex mods and make target.
  699. X14. Fixed path delimiter under VMS for unship.
  700. X15. Added ship to makevms.com.
  701. X16. Put in new copyright messages.
  702. X17. Added aix make target.
  703. X18. Fixed zipsplit.idx to start counting at one like the file names.
  704. X19. Changed -a (append VMS version number) to -w to leave -a open for a
  705. X    possible future option.
  706. X20. Back to separate makefiles for Microsoft and Borland (.msc and .bor).
  707. X21. Workaround in fileio.c for Borland stat() bug: stat() succeeds for wild
  708. X    card names that match existing files.
  709. X22. Added "(did you remember to use binary mode when you transferred it?)"
  710. X    to the "probably not a zip file" warning.
  711. X23. Changed utilities to append .zip only when the zip file name does not
  712. X    contain a dot.
  713. X24. At least mentioned the other utilities in zip.doc (zipcloak, ship, etc.),
  714. X    and documented upper case matching of names when using -d under MSDOS.
  715. X25. Fixed bug in MSDOS version: zip foo c:autoexec.bat wouldn't work.
  716. X26. Added hidden/system attribute bug to BUGS in zip.1
  717. X27. Fixed recognition of unship in ship when unship is in a path.
  718. X28. Added non-stream-LF VMS bug to zip.1 bug list.
  719. X29. Fixed bug in #23 above when path has dots.  Documented #23 in zip.1.
  720. X30. Show disclaimer only for -l, add -h and -l to zip utilities.
  721. X31. Applied Minix patches.
  722. END_OF_FILE
  723.   if test 36825 -ne `wc -c <'History'`; then
  724.     echo shar: \"'History'\" unpacked with wrong size!
  725.   fi
  726.   # end of 'History'
  727. fi
  728. if test -f 'makefile.pwc' -a "${1}" != "-c" ; then 
  729.   echo shar: Will not clobber existing file \"'makefile.pwc'\"
  730. else
  731.   echo shar: Extracting \"'makefile.pwc'\" \(3619 characters\)
  732.   sed "s/^X//" >'makefile.pwc' <<'END_OF_FILE'
  733. X# Makefile for Zip, ZipNote, ZipSplit, and Ship, for Power C.
  734. X
  735. X# This version by Bob Hardy, 07-16-91
  736. X
  737. X# Make sure you have plenty of free diskspace before invoking make,
  738. X# especially for "make zips".  If you run out of space, several lines
  739. X# will lose dramatically, and the make will fail.  You may even have
  740. X# to rename some source files.
  741. X
  742. XCC=pc
  743. XLD=pcl
  744. XMODEL=m
  745. X# (note from the editor: the "m" here for MODEL looks a little suspicious--
  746. X#  it probably should be s or c, since the small or compact models are what
  747. X#  should be used.)
  748. XCFLAGS=/f- /m$(MODEL) /dMSDOS /dNO_ASM /dEXPORT
  749. XLDFLAGS=/d 
  750. XSTRIP=lzexe
  751. X# If you don't have lzexe, get it. Then define:
  752. X#    STRIP=lzexe
  753. X# This makes a *big* difference in .exe size (hence load time)
  754. X# If you want to make without it, comment out all the STRIP lines and the
  755. X# "rm *.old" lines.  This will cost you in terms of disk usage, though.
  756. X
  757. X# variables
  758. XOBJZ1 = zip.mix zipfile.mix zipup.mix fileio.mix util.mix
  759. XOBJZ2 = shrink.mix globals.mix tempf.mix
  760. XOBJC2 = util.mix globals.mix
  761. XOBJI = implode.mix im_lmat.mix im_ctree.mix im_bits.mix
  762. XOBJN = zipnote.mix zipfile_.mix zipup_.mix fileio_.mix globals.mix
  763. XOBJS = zipsplit.mix zipfile_.mix zipup_.mix fileio_.mix globals.mix
  764. X
  765. Xzips:        zip.exe zipnote.exe zipsplit.exe ship.exe
  766. X
  767. Xzip.mix:    zip.h ziperr.h tailor.h revision.h zip.c
  768. X    $(CC) $(CFLAGS) zip.c
  769. X
  770. Xzipfile.mix:    zip.h ziperr.h tailor.h zipfile.c
  771. X    $(CC) $(CFLAGS) zipfile.c
  772. X
  773. Xzipup.mix:    zip.h ziperr.h tailor.h revision.h zipup.c
  774. X    $(CC) $(CFLAGS) zipup.c
  775. X
  776. Xfileio.mix:    zip.h ziperr.h tailor.h fileio.c
  777. X    $(CC) $(CFLAGS) fileio.c
  778. X
  779. Xutil.mix:    zip.h ziperr.h tailor.h util.c
  780. X    $(CC) $(CFLAGS) util.c
  781. X
  782. Xshrink.mix:    zip.h ziperr.h tailor.h shrink.c
  783. X    $(CC) $(CFLAGS) shrink.c
  784. X
  785. Xglobals.mix:    zip.h ziperr.h tailor.h globals.c
  786. X    $(CC) $(CFLAGS) globals.c
  787. X
  788. Xzipnote.mix:    zip.h ziperr.h tailor.h revision.h zipnote.c
  789. X    $(CC) $(CFLAGS) zipnote.c
  790. X
  791. Xzipsplit.mix: zipsplit.c zip.h ziperr.h tailor.h revision.h
  792. X    $(CC) $(CFLAGS) zipsplit.c
  793. X
  794. Ximplode.mix:    implode.h crypt.h ziperr.h tailor.h tempf.h implode.c
  795. X    $(CC) $(CFLAGS) implode.c
  796. X
  797. Xtempf.mix:    tempf.h tailor.h tempf.c
  798. X    $(CC) $(CFLAGS) tempf.c
  799. X
  800. Xim_lmat.mix:    implode.h crypt.h ziperr.h tailor.h im_lmat.c
  801. X    $(CC) $(CFLAGS) im_lmat.c
  802. X
  803. Xim_ctree.mix:    implode.h crypt.h ziperr.h tailor.h tempf.h im_ctree.c
  804. X    $(CC) $(CFLAGS) im_ctree.c
  805. X
  806. Xim_bits.mix:    implode.h crypt.h ziperr.h tailor.h im_bits.c
  807. X    $(CC) $(CFLAGS) im_bits.c
  808. X
  809. Xzipfile_.mix: zipfile.c zip.h
  810. X    +ren zipfile.c zipfile_.c
  811. X    $(CC) /dUTIL $(CFLAGS) zipfile_.c
  812. X    +ren zipfile_.c zipfile.c
  813. X
  814. Xzipup_.mix: zipup.c zip.h
  815. X    +ren zipup.c zipup_.c
  816. X    $(CC) /dUTIL $(CFLAGS) zipup_.c
  817. X    +ren zipup_.c zipup.c
  818. X
  819. Xfileio_.mix: fileio.c zip.h
  820. X    +ren fileio.c fileio_.c
  821. X    $(CC) /dUTIL $(CFLAGS) fileio_.c
  822. X    +ren fileio_.c fileio.c
  823. X
  824. X# we must cut the command line to fit in the MS/DOS 128 byte limit:
  825. Xzip.exe: $(OBJZ1) $(OBJZ2) $(OBJI)
  826. X    +echo L $(OBJZ1) > zip.rsp
  827. X    +echo L $(OBJZ2) >> zip.rsp
  828. X    +echo L $(OBJI) >> zip.rsp
  829. X    +echo FA; >> zip.rsp
  830. X    +echo b zip,,, >> zip.rsp
  831. X    $(LD) $(LDFLAGS) @zip.rsp
  832. X    rm zip.rsp
  833. X    $(STRIP) zip.exe
  834. X#    rm zip.old
  835. X# Leave these "rm *.old" lines in if you have a shortage of diskspace.
  836. X# Particularly if you intend to "make zips".
  837. X
  838. Xzipnote.exe: $(OBJN)
  839. X    +echo L $(OBJN) > zipn.rsp
  840. X    +echo FA; >> zipn.rsp
  841. X    +echo b zipnote,,, >> zipn.rsp
  842. X    $(LD) $(LDFLAGS) @zipn.rsp
  843. X    rm zipn.rsp
  844. X    $(STRIP) zipnote.exe
  845. X#    rm zipnote.old
  846. X
  847. Xzipsplit.exe: $(OBJS)
  848. X    +echo L $(OBJS) > zips.rsp
  849. X    +echo FA; >> zips.rsp
  850. X    +echo b zipsplit,,, >> zips.rsp
  851. X    $(LD) $(LDFLAGS) @zips.rsp
  852. X    rm zips.rsp
  853. X    $(STRIP) zipsplit.exe
  854. X#    rm zipsplit.old
  855. X
  856. Xship.exe: ship.c
  857. X    $(CC) $(CFLAGS) ship.c
  858. X    $(LD) $(LDFLAGS) ship.mix
  859. X    $(STRIP) ship.exe
  860. X#    rm ship.old
  861. END_OF_FILE
  862.   if test 3619 -ne `wc -c <'makefile.pwc'`; then
  863.     echo shar: \"'makefile.pwc'\" unpacked with wrong size!
  864.   fi
  865.   # end of 'makefile.pwc'
  866. fi
  867. if test -f 'shrink.c' -a "${1}" != "-c" ; then 
  868.   echo shar: Will not clobber existing file \"'shrink.c'\"
  869. else
  870.   echo shar: Extracting \"'shrink.c'\" \(10431 characters\)
  871.   sed "s/^X//" >'shrink.c' <<'END_OF_FILE'
  872. X/*
  873. X
  874. X Copyright (C) 1990,1991 Mark Adler, Richard B. Wales, and Jean-loup Gailly.
  875. X Permission is granted to any individual or institution to use, copy, or
  876. X redistribute this software so long as all of the original files are included
  877. X unmodified, that it is not sold for profit, and that this copyright notice
  878. X is retained.
  879. X
  880. X*/
  881. X
  882. X/*
  883. X *  shrink.c by Mark Adler.
  884. X */
  885. X
  886. X#include "zip.h"
  887. X#include "tempf.h"
  888. X
  889. X
  890. X/*
  891. X   Shrink.Pas version 1.2 by R. P. Byrne, 1989 (in Pascal and assembler).
  892. X   We here heartily acknowledge R. P. Byrne's contribution to this project.
  893. X   The existence of this program really triggered our efforts to write a
  894. X   portable Unix zip.  What little remains of Byrne's program lies in this
  895. X   source file, and those remnants are mostly in the variable and routine
  896. X   names, since it has been translated and extensively modified and rewritten.
  897. X
  898. X   Stolen, translated into C, and modified by Mark Adler, 11 October 1990.
  899. X   Severely modified again by Mark Adler, 11 July 1991, to remove the
  900. X   unnecessary FreeList and ClearTable arrays, and to replace the recursive
  901. X   Prune() routine with a non-recursive method.
  902. X   As Stravinsky once said: "Mediocre composers plagiarize.
  903. X                             Great composers steal."
  904. X*/
  905. X
  906. X/*   Compress a set of input files into a Zip file using Lempel-Ziv-Welch */
  907. X/*   (LZW) compression techniques (the "shrink" method). */
  908. X
  909. X
  910. X#define MINBITS         9       /* Starting code size of 9 bits */
  911. X#define MAXBITS         13      /* Maximum code size of 13 bits */
  912. X#define TABLESIZE       8191    /* We'll need 4K entries in table */
  913. X#define SPECIAL         256     /* Special function code */
  914. X#define INCSIZE         1       /* Code for a jump in code size */
  915. X#define CLEARCODE       2       /* Code for code table has been cleared */
  916. X#define FIRSTENTRY      257     /* First available table entry */
  917. X
  918. X
  919. X/* Define data types needed to implement a code table for LZW compression */
  920. X
  921. Xtypedef struct CodeRec {
  922. X  /* Code Table record format... */
  923. X  short Child;          /* Addr of 1st suffix for this prefix */
  924. X  short Sibling;        /* Addr of next suffix in chain */
  925. X  uch Suffix;           /* Suffix character */
  926. X} CodeRec;
  927. X
  928. Xtypedef CodeRec CodeArray[TABLESIZE + 1];       /* Define the code table */
  929. X
  930. X
  931. X
  932. X/* Private globals */
  933. Xlocal CodeRec far *CodeTable;   /* Points to code table for LZW compression */
  934. X
  935. Xlocal int NextFree;     /* Next free table entry */
  936. X
  937. Xlocal int CodeSize;     /* Size of codes (in bits) currently being written */
  938. Xlocal int MaxCode;      /* Largest code that can be written in CodeSize bits */
  939. X
  940. Xlocal int FirstCh;      /* Flag indicating the START of a shrink operation */
  941. X
  942. Xlocal tFILE *tempf = NULL;      /* Temporary file */
  943. Xlocal ulg count;                /* Count of bytes written */
  944. X
  945. X
  946. X/* Local functions */
  947. X#ifdef PROTO
  948. X   local void PutCode(int);
  949. X   local int Build_Data_Structures(void);
  950. X   local void Destroy_Data_Structures(void);
  951. X   local void Initialize_Data_Structures(void);
  952. X   local void Clear_Table(void);
  953. X   local void Table_Add(int, int);
  954. X#endif /* PROTO */
  955. X
  956. X
  957. X/* Macro for PutCode() that writes to tempf and counts bytes in count */
  958. X#define PUT(c) {tputc(c, tempf); count++;}
  959. X
  960. Xlocal void PutCode(c)
  961. Xint c;                  /* code to send */
  962. X/* Write out the low CodeSize bits of c using the PUT macro.  If c is -1,
  963. X   then flush the bit buffer.  Assumes CodeSize < 16.  By Mark Adler. */
  964. X{
  965. X  static int b = 0;     /* current bits waiting to go out */
  966. X  static int n = 0;     /* number of bits in b */
  967. X  /* masks for all bit values */
  968. X  static int x[] = {0, 1, 3, 7, 0xf, 0x1f, 0x3f, 0x7f, 0xff, 0x1ff,
  969. X                0x3ff, 0x7ff, 0xfff, 0x1fff, 0x3fff, 0x7fff, 0xffff};
  970. X
  971. X  if (c == -1)
  972. X  {
  973. X    if (n)
  974. X    {
  975. X      if (n > 8)
  976. X      {
  977. X        PUT((char)b)
  978. X        PUT((char)((b >> 8) & x[n - 8]))
  979. X      }
  980. X      else
  981. X        PUT((char)(b & x[n]))
  982. X      b = n = 0;
  983. X    }
  984. X  }
  985. X  else
  986. X  {
  987. X    b |= (c & x[CodeSize]) << n;
  988. X    n += CodeSize;
  989. X    if (n >= 16)
  990. X    {
  991. X      PUT((char)b)
  992. X      PUT((char)(b >> 8))
  993. X      if (n == 16)
  994. X        b = n = 0;
  995. X      else
  996. X      {
  997. X        n -= 16;
  998. X        b = (c >> (CodeSize - n)) & x[n];
  999. X      }
  1000. X    }
  1001. X  }
  1002. X}
  1003. X
  1004. X
  1005. X
  1006. Xlocal int Build_Data_Structures()
  1007. X/* Allocate tables for shrinking.  Return true on failure. */
  1008. X{
  1009. X  return (CodeTable = (CodeRec far *)farmalloc(sizeof(CodeArray))) == NULL;
  1010. X}
  1011. X
  1012. X
  1013. X
  1014. Xlocal void Destroy_Data_Structures()
  1015. X/* Deallocate tables for shrinking. */
  1016. X{
  1017. X  if (CodeTable != NULL)
  1018. X  {
  1019. X    farfree((voidp far *)CodeTable);
  1020. X    CodeTable = NULL;
  1021. X  }
  1022. X}
  1023. X
  1024. X
  1025. X
  1026. Xlocal void Initialize_Data_Structures()
  1027. X/* Clear tables for shrinking. */
  1028. X{
  1029. X  int i;                /* counter for table entries */
  1030. X  CodeRec far *t;       /* pointer to current table entry */
  1031. X
  1032. X  /* Initialize parent symbols */
  1033. X  for (i = 0, t = CodeTable; i <= 255; i++, t++)
  1034. X  {
  1035. X    t->Child = -1;
  1036. X    t->Suffix = (uch)i;
  1037. X  }
  1038. X
  1039. X  /* Build free list */
  1040. X  NextFree = FIRSTENTRY;
  1041. X  for (i = FIRSTENTRY, t = CodeTable + FIRSTENTRY; i < TABLESIZE; i++, t++)
  1042. X    t->Child = i + 1;
  1043. X  t->Child = -1;
  1044. X}
  1045. X
  1046. X
  1047. X
  1048. Xlocal void Clear_Table()
  1049. X/* Clear the leaves of the tree--assume all entries used (NextFree == -1) */
  1050. X{
  1051. X  int n;                /* node counter */
  1052. X  CodeRec far *p;       /* pointer to next node to look at */
  1053. X  short far *q;         /* pointer to node child or sibling entry */
  1054. X
  1055. X  /* Mark leaf nodes */
  1056. X  p = CodeTable + TABLESIZE;
  1057. X  n = TABLESIZE + 1 - FIRSTENTRY;
  1058. X  do {
  1059. X    if (p->Child == -1)
  1060. X      p->Child = -2;
  1061. X    p--;
  1062. X  } while (--n);
  1063. X
  1064. X  /* Shake leaves from tree */
  1065. X  p = CodeTable;
  1066. X  n = 256;
  1067. X  do {
  1068. X    q = &p->Child;
  1069. X    while (*q != -1 && CodeTable[*q].Child == -2)
  1070. X      *q = CodeTable[*q].Sibling;
  1071. X    p++;
  1072. X  } while (--n);
  1073. X  p = CodeTable + FIRSTENTRY;
  1074. X  n = TABLESIZE + 1 - FIRSTENTRY;
  1075. X  do {
  1076. X    if (p->Child != -2)
  1077. X    {
  1078. X      q = &p->Child;
  1079. X      while (*q != -1 && CodeTable[*q].Child == -2)
  1080. X        *q = CodeTable[*q].Sibling;
  1081. X      q = &p->Sibling;
  1082. X      while (*q != -1 && CodeTable[*q].Child == -2)
  1083. X        *q = CodeTable[*q].Sibling;
  1084. X    }
  1085. X    p++;
  1086. X  } while (--n);
  1087. X
  1088. X  /* Build the list of free table entries */
  1089. X  NextFree = -1;
  1090. X  p = CodeTable + TABLESIZE;
  1091. X  n = TABLESIZE + 1 - FIRSTENTRY;
  1092. X  do {
  1093. X    if (p->Child == -2)
  1094. X    {
  1095. X      p->Child = NextFree;
  1096. X      NextFree = n + FIRSTENTRY - 1;
  1097. X    }
  1098. X    p--;
  1099. X  } while (--n);
  1100. X}
  1101. X
  1102. X
  1103. X
  1104. Xlocal void Table_Add(p, s)
  1105. Xint p;                  /* prefix to add to */
  1106. Xint s;                  /* suffix to add to it */
  1107. X/* Add an entry to the table. */
  1108. X{
  1109. X  int f;                /* next free node */
  1110. X
  1111. X  if ((f = NextFree) != -1)
  1112. X  {
  1113. X    NextFree = CodeTable[f].Child;
  1114. X    CodeTable[f].Child = -1;
  1115. X    CodeTable[f].Sibling = -1;
  1116. X    CodeTable[f].Suffix = (uch)s;
  1117. X    if (CodeTable[p].Child == -1)
  1118. X      CodeTable[p].Child = f;
  1119. X    else
  1120. X    {
  1121. X      p = CodeTable[p].Child;
  1122. X      while (CodeTable[p].Sibling != -1)
  1123. X        p = CodeTable[p].Sibling;
  1124. X      CodeTable[p].Sibling = f;
  1125. X    }
  1126. X  }
  1127. X}
  1128. X
  1129. X
  1130. Xlocal int lastcode;
  1131. X
  1132. Xint shr_setup()
  1133. X/* Initialize shrink() routines.  Return an error code in the ZE_ class. */
  1134. X{
  1135. X  if (Build_Data_Structures())
  1136. X    return ZE_MEM;
  1137. X  Initialize_Data_Structures();
  1138. X  FirstCh = 1;
  1139. X  lastcode = -1;
  1140. X  if ((tempf = topen('S')) == NULL)
  1141. X    return ZE_MEM;
  1142. X  count = 0;
  1143. X  return ZE_OK;
  1144. X}
  1145. X
  1146. X
  1147. Xint shr_p1(b, n)
  1148. Xuch *b;                 /* buffer with bytes to shrink */
  1149. Xextent n;               /* number of bytes in buffer */
  1150. X/* Shrink n bytes at *b.  Return an error code in the ZE_ class. */
  1151. X{
  1152. X  int f;                /* result of Table_Lookup */
  1153. X  int s;                /* byte to shrink */
  1154. X
  1155. X  if (FirstCh && n)
  1156. X  {                             /* If just getting started ... */
  1157. X    CodeSize = MINBITS;         /*   Initialize code size to minimum */
  1158. X    MaxCode = (1 << CodeSize) - 1;
  1159. X    lastcode = *b++;  n--;      /*   get first character from input, */
  1160. X    FirstCh = 0;                /*   and reset the first char flag. */
  1161. X  }
  1162. X  while (NextFree == -1 && n)
  1163. X  {
  1164. X    /* Ok, lets clear the code table (adaptive reset) */
  1165. X    PutCode(lastcode);
  1166. X    PutCode(SPECIAL);
  1167. X    PutCode(CLEARCODE);
  1168. X    Clear_Table();
  1169. X    Table_Add(lastcode, s = *b++);  n--;
  1170. X    lastcode = s;
  1171. X  }
  1172. X  while (n)
  1173. X  {
  1174. X    s = *b++;  n--;
  1175. X    f = CodeTable[lastcode].Child;
  1176. X    while (f != -1 && CodeTable[f].Suffix != (uch)s)
  1177. X      f = CodeTable[f].Sibling;
  1178. X    if (f != -1)
  1179. X      /* If lastcode:s pair is found in the code table, then ... */
  1180. X      /* ... set lastcode to the entry where the pair is located */
  1181. X      lastcode = f;
  1182. X    else
  1183. X    {
  1184. X      /* Not in table */
  1185. X      PutCode(lastcode);        /* Write current lastcode */
  1186. X      Table_Add(lastcode, s);   /* Attempt to add to code table */
  1187. X      lastcode = s;             /* Reset lastcode for new char */
  1188. X      if (NextFree > MaxCode && CodeSize < MAXBITS)
  1189. X      {
  1190. X        /* Time to increase the code size and change the max. code */
  1191. X        PutCode(SPECIAL);
  1192. X        PutCode(INCSIZE);
  1193. X        CodeSize++;
  1194. X        MaxCode = (1 << CodeSize) - 1;
  1195. X      }
  1196. X      while (NextFree == -1 && n)
  1197. X      {
  1198. X        /* Ok, lets clear the code table (adaptive reset) */
  1199. X        PutCode(lastcode);
  1200. X        PutCode(SPECIAL);
  1201. X        PutCode(CLEARCODE);
  1202. X        Clear_Table();
  1203. X        Table_Add(lastcode, s = *b++);  n--;
  1204. X        lastcode = s;
  1205. X      }
  1206. X    }
  1207. X  }
  1208. X  return ZE_OK;
  1209. X}
  1210. X
  1211. X
  1212. Xint shr_size(s)
  1213. Xulg *s;                 /* return value: size of shrunk data */
  1214. X/* End shrink and return size of shrunk data in *s.  Return an error code in
  1215. X   the ZE_ class. */
  1216. X{
  1217. X  PutCode(lastcode);            /* Write last prefix code */
  1218. X  PutCode(-1);                  /* Tell putcode to flush remaining bits */
  1219. X  Destroy_Data_Structures();
  1220. X  *s = count;
  1221. X  return tflush(tempf) || terror(tempf) ? ZE_TEMP : ZE_OK;
  1222. X}
  1223. X
  1224. X
  1225. Xint shr_p2(f)
  1226. XFILE *f;                /* file to write shrunk data to */
  1227. X/* Copy shrunk data from temporary file to zip file *f.  Return an error
  1228. X   code in the ZE_ class. */
  1229. X{
  1230. X  char *b;              /* malloc'ed buffer for copying */
  1231. X  extent k;             /* holds result of fread */
  1232. X
  1233. X  if ((b = malloc(BSZ)) == NULL)
  1234. X    return ZE_MEM;
  1235. X  trewind(tempf);
  1236. X  while ((k = tread(b, 1, BSZ, tempf)) > 0)
  1237. X    if (zfwrite(b, 1, k, f) != k)
  1238. X    {
  1239. X      free((voidp *)b);
  1240. X      return ZE_TEMP;
  1241. X    }
  1242. X  free((voidp *)b);
  1243. X  if (terror(tempf))
  1244. X    return ZE_TEMP;
  1245. X  tclose(tempf);
  1246. X  tempf = NULL;
  1247. X  return ZE_OK;
  1248. X}
  1249. X
  1250. X
  1251. Xint shr_clear()
  1252. X/* Terminate shrink procedure (at any time).  Return an error code in
  1253. X   the ZE_ class (always ZE_OK). */
  1254. X{
  1255. X  Destroy_Data_Structures();
  1256. X  if (tempf != NULL)
  1257. X  {
  1258. X    tclose(tempf);
  1259. X    tempf =  NULL;
  1260. X  }
  1261. X  return ZE_OK;
  1262. X}
  1263. END_OF_FILE
  1264.   if test 10431 -ne `wc -c <'shrink.c'`; then
  1265.     echo shar: \"'shrink.c'\" unpacked with wrong size!
  1266.   fi
  1267.   # end of 'shrink.c'
  1268. fi
  1269. if test -f 'zip.def' -a "${1}" != "-c" ; then 
  1270.   echo shar: Will not clobber existing file \"'zip.def'\"
  1271. else
  1272.   echo shar: Extracting \"'zip.def'\" \(86 characters\)
  1273.   sed "s/^X//" >'zip.def' <<'END_OF_FILE'
  1274. XNAME WINDOWCOMPAT NEWFILES
  1275. XDESCRIPTION 'The world-famous zip utilities from Info-ZIP'
  1276. END_OF_FILE
  1277.   if test 86 -ne `wc -c <'zip.def'`; then
  1278.     echo shar: \"'zip.def'\" unpacked with wrong size!
  1279.   fi
  1280.   # end of 'zip.def'
  1281. fi
  1282. echo shar: End of archive 4 \(of 9\).
  1283. cp /dev/null ark4isdone
  1284. MISSING=""
  1285. for I in 1 2 3 4 5 6 7 8 9 ; do
  1286.     if test ! -f ark${I}isdone ; then
  1287.     MISSING="${MISSING} ${I}"
  1288.     fi
  1289. done
  1290. if test "${MISSING}" = "" ; then
  1291.     echo You have unpacked all 9 archives.
  1292.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1293. else
  1294.     echo You still must unpack the following archives:
  1295.     echo "        " ${MISSING}
  1296. fi
  1297. exit 0
  1298. exit 0 # Just in case...
  1299. -- 
  1300. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1301. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1302. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1303. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1304.